package com.naizhuai.ui.rank.multType;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.naizhuai.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import me.drakeet.multitype.ItemViewBinder;

/**
 * @author：lichenxi
 * @date 2018/5/17 11
 * email：525603977@qq.com
 * Fighting
 */
public class OrganizeActiveViewBinder extends ItemViewBinder<OrganizeActive, OrganizeActiveViewBinder.ViewHolder> {



    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_organize_active, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull OrganizeActive organizeActive) {
        holder.itemView.post(new Runnable() {
            @Override
            public void run() {
               int width= holder.realtimeLine.getWidth();
                setWidth(holder.realtime,width/3);
                setWidth(holder.inquarter,(int) (width/1.2));

            }
        });
    }

  protected void setWidth(View view,int width){
      RelativeLayout.LayoutParams params= (RelativeLayout.LayoutParams) view.getLayoutParams();
      params.width=width;
      view.setLayoutParams(params);
  }
    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.active_value)
        TextView activeValue;
        @BindView(R.id.realtime_line)
        View realtimeLine;
        @BindView(R.id.realtime)
        View realtime;
        @BindView(R.id.inquarter_line)
        View inquarterLine;
        @BindView(R.id.inquarter)
        View inquarter;
        ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
